<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>递归</h1>
    <script>
        function add(n) {
            if (n == 1) {
                return 1;
            } else {
                return add(n - 1) + n;
            }
        }
        function addd(n) {
            if (n == 1) {
                return 1;
            } else {
                return addd(n - 1) * n;
            }
        }
        function fabo(n) {
            if (n == 0) {
                return 0;
            } else if (n == 1) {
                return 1;
            } else {
                return fabo(n - 1) + fabo(n - 2);
            }
        }
        var root = {
            name: 'C盘',
            children: [{
                name: '学习',
                children: [{
                    name: "电子书",
                    children: [{
                        name: "文学",
                        children: [{
                            name: "三体"
                        },
                        { name: "红与黑" }
                        ]
                    }]
                }]
            }, {
                name: "电影",
                children: [
                    { name: "美国电影" },
                    { name: "日本电影" }
                ]
            }]
        }
        console.log(fabo(7));
        console.log(add(5));
        console.log(addd(5));
        console.log(root);
    </script>
</body>

</html>